<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page language="java" import="java.sql.*,java.io.*,java.util.*"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">  
table {  
    border: 2px #CCCCCC solid;  
    width: 360px;  
}  
  
td,th {  
    height: 30px;  
    border: #CCCCCC 1px solid;  
}  
</style>
</head>
<body>
<%
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String password = "";
Connection conn = null;
String dbname="mysql";
String tabelname="user1";
String url = "jdbc:mysql://localhost:3306/" + dbname + "?user="  
        + username + "&password=" + password;
Class.forName("com.mysql.jdbc.Driver").newInstance();  
Connection connection = DriverManager.getConnection(url);  
Statement statement = connection.createStatement();  
String sql = "SELECT * FROM " + tabelname;  
ResultSet rs = statement.executeQuery(sql); 
%>
 <table align="center">  
   <tr>  
    <th>  
     <%  
      out.print("id");  
     %>  
    </th>  
    <th>  
     <%  
      out.print("name");  
     %>  
    </th>  
    <th>  
     <%  
      out.print("age");  
     %>  
    </th>    
   </tr>  
     <%  
       while (rs.next()) {  
     %>  
     <tr>  
      <td>  
       <%  
       out.print(rs.getInt(1));  
       %>  
      </td>  
      <td>  
       <%  
       out.print(rs.getString(2));  
       %>  
      </td>  
      <td>  
       <%  
        out.print(rs.getInt(3));  
       %>  
      </td>        
     </tr>  
       <%  
       }  
       %>  
    </table>  
    <div align="center">  
        <br> <br> <br>  
        <%  
            out.print("数据查询成功，恭喜你");  
        %>  
    </div>  
    <%  
        rs.close();  
        statement.close();  
        connection.close();  
    %>  
    </table>  
</body>
</html>
</span><span style="font-size:24px;color: rgb(255, 0, 0);">  
</span></span>  